// 单张扑克
function Poker(number, color) {
  this.number = number;
  this.color = color;
}

Poker.prototype.print = function () {
  if (this.number === 14) {
    console.log("joker");
    return;
  }

  if (this.number === 15) {
    console.log("JOKER");
    return;
  }

  const colors = ["♠", "♥", "♣", "♦"];
  const numbers = [
    "A",
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "10",
    "J",
    "Q",
    "K",
  ];

  const color = colors[this.color - 1];
  const number = numbers[this.number];
  console.log(`${color}${number}`);
};

// 一份扑克牌
function Deck() {
  this.pocker = [];
}

Deck.prototype.createDeck = function () {
  for (let i = 1; i <= 13; i++) {
    for (let j = 1; j <= 4; j++) {
      this.pocker.push(new Poker(i, j));
    }
  }

  this.pocker.push(new Poker(14));
  this.pocker.push(new Poker(15));
};

Deck.prototype.print = function () {
  this.pocker.forEach((item) => {
    item.print();
  });
};

const d = new Deck();
d.createDeck();
d.print();
